package com.rh.excrptions;

import com.rh.Enums;

/**
 * 创建一个异常类,继承RuntimeException
 */
public class DoException extends RuntimeException {
    //异常代码
    private Integer code;
    //异常提示消息
    private String msg;

    //有参构造使用枚举类的状态码和消息
    public DoException(Enums enums){
        this.code=enums.getCode();
        this.msg=enums.getMsg();
    }
    @Override
    public String toString() {
        return "DoException{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                '}';
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
